import React, { useContext, useState } from 'react';
import './leftbar.scss'
import StackedLineChartIcon from '@mui/icons-material/StackedLineChart';
import FormatListNumberedIcon from '@mui/icons-material/FormatListNumbered';
import '../../hover.css'
import { Link, useNavigate } from 'react-router-dom'
import { AuthContext } from '../../context/authContext';

const LeftBar = () => {

    const navigate = useNavigate()

    const handleBwicClick = () => {navigate('/')}

    const handleStatisticsClick = () =>{navigate('/statistics')}

    const {currentUser, setCurrentUser} = useContext(AuthContext)

  return (
    <div className='leftbar'>
        <div className="menu">
            <div className="item hvr-sweep-to-right" onClick={handleBwicClick}>
                <FormatListNumberedIcon/>
                <span>查看BWIC</span>
            </div>
            {
                currentUser.assetValue<0 ?
                    <div className="item hvr-sweep-to-right" onClick={handleStatisticsClick}>
                        <StackedLineChartIcon/>
                        <span>数据分析</span>
                    </div>                                             
                    :null                  
                        
            }

        </div>
    </div>
  )
}

export default LeftBar